﻿namespace IceDog.DNL.CSharp.DesignPattern.ServiceLocatorPattern.Member
{
    public class ServiceLocator
    {
        private static readonly MemberCache Cache;

        static ServiceLocator()
        {
            Cache = new MemberCache();
        }

        public static IMemberService GetService(MemberServiceType serviceName)
        {

            IMemberService service = Cache.GetService(serviceName);

            if (service != null)
            {
                return service;
            }
            MemberContext context = new MemberContext();
            IMemberService service1 = context.Lookup(serviceName);
            Cache.AddService(service1);
            return service1;
        }
}
}
